﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="User.ascx.cs" Inherits="ERP.Modules.User" %>
<%-------------------------------%>
<ext:Hidden ID="FormatTypeUser" runat="server" />
<ext:Panel runat="server" Layout="Fit" Border="False" ID="PanelUserMain">
    <Content>
        <%--------------GridUser-----------------%>
        <ext:GridPanel
            ID="grUser"
            Cls="grid-double"
            runat="server"
            EnableColumnMove="true"
            Border="False">
            <%-------------StoreUser-----------------%>
            <Store>
                <ext:Store
                    ID="StoreUser"
                    runat="server"
                    OnReadData="StoreUser_RefreshData"
                    PageSize="20">
                    <Model>
                        <ext:Model ID="ModelUser" runat="server" IDProperty="Users_Id" GroupField="Group_Name">
                            <Fields>
                                <ext:ModelField Name="Group_Name" Type="String" />
                                <ext:ModelField Name="UserName" Type="String" />
                                <ext:ModelField Name="FullName" Type="String" />
                                <ext:ModelField Name="CreatedDate" Type="Date" />
                                <ext:ModelField Name="LastLogIn" Type="Date" />
                                <ext:ModelField Name="LastChangedPassword" Type="Date" />
                                <ext:ModelField Name="Note" Type="String" />
                                <ext:ModelField Name="IsActive" Type="Boolean" />
                                <ext:ModelField Name="IsUsed" Type="Boolean" />
                            </Fields>
                        </ext:Model>
                    </Model>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:RowNumbererColumn ID="RowNumbererColumnUser" runat="server" Width="30" Align="Center" />
                    <ext:Column runat="server" Text="Nhóm quyền" Width="109" DataIndex="Group_Name"></ext:Column>
                    <ext:Column runat="server" Text="Tên đăng nhập" Width="104" DataIndex="UserName"></ext:Column>
                    <ext:Column runat="server" Text="Tên nhân viên" Width="150" DataIndex="FullName"></ext:Column>
                    <ext:DateColumn runat="server" Text="Ngày tạo" Width="106" DataIndex="CreatedDate" Format="dd-MM-yyyy" Align="Center"></ext:DateColumn>
                    <ext:DateColumn runat="server" Text="Đăng nhập gần nhất" Width="135" DataIndex="LastLogIn" Format="dd-MM-yyyy" Align="Center"></ext:DateColumn>
                    <ext:DateColumn runat="server" Text="Đổi mật khẩu gần nhất" Width="140" DataIndex="LastChangedPassword" Format="dd-MM-yyyy" Align="Center"></ext:DateColumn>
                    <ext:CheckColumn runat="server" Text="Khoá" Width="80" DataIndex="IsActive" Align="Center"></ext:CheckColumn>
                    <ext:CheckColumn runat="server" Text="Trạng thái" Width="80" DataIndex="IsUsed" Align="Center"></ext:CheckColumn>
                    <ext:Column runat="server" Text="Ghi chú" Width="146" DataIndex="Note" Flex="1"></ext:Column>
                </Columns>
            </ColumnModel>
            <Features>
                <ext:Grouping 
                    runat="server" 
                    HideGroupedHeader="true"
                    GroupByText="Xem theo phân nhóm"
                    ShowGroupsText="Phân nhóm"
                    GroupHeaderTplString="{name} ({rows.length} danh mục con {[values.rows.length > 1 ? '' : '']})"
                    StartCollapsed="True" />
            </Features>
            <DirectEvents>
                <ItemDblClick OnEvent="UserDblClick">
                    <ExtraParams>
                        <ext:Parameter Name="Users_Id" Value="record.data.Users_Id" Mode="Raw" />
                    </ExtraParams>
                    <EventMask ShowMask="true" Msg="Đang tải..." />
                </ItemDblClick>
            </DirectEvents>
            <SelectionModel>
                <ext:CheckboxSelectionModel runat="server" Mode="Multi">
                     <Listeners>
                       <SelectionChange Handler="
                            if (selected.length == 0) {
                                #{btnEdit}.disable();
                                #{btnDel}.disable();
                                #{btnExport}.disable();
                            } else {
                                #{btnEdit}.enable();
                                #{btnDel}.enable();
                                #{btnExport}.enable();
                            }" />
                   </Listeners>
                </ext:CheckboxSelectionModel>
            </SelectionModel>
            <DockedItems>
                <ext:Toolbar ID="ToolbarTopMain" runat="server" Dock="Top">
                    <Items>
                        <ext:Button ID="btnAddNew" runat="server" Text="Thêm mới" Icon="ApplicationAdd">
                            <DirectEvents>
                                <Click OnEvent="btnAddNew_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button ID="btnEdit" runat="server" Text="Sửa" Icon="ApplicationEdit">
                            <DirectEvents>
                                <Click OnEvent="btnEdit_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button ID="btnDel" runat="server" Text="Xoá" Icon="ApplicationDelete">
                            <DirectEvents>
                                <Click OnEvent="btnDel_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                    <ExtraParams>
                                        <ext:Parameter Name="name" Value="btnDel"></ext:Parameter>
                                    </ExtraParams>
                                    <Confirmation ConfirmRequest="true"
                                        Title="Thông Báo" Message="Bạn có muốn xoá mẫu tin này không ?">
                                    </Confirmation>
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button ID="btnExport" runat="server" Text="Xuất tập tin" Icon="Printer">
                            <Menu>
                                <ext:Menu ID="MenuMain" runat="server">
                                    <Items>
                                        <ext:MenuItem ID="MenuItemExportXML" runat="server" Text="XML" Icon="PageCode">
                                            <Listeners>
                                                <Click Handler="submitValue(#{grUser}, #{FormatTypeUser}, 'xml');" />
                                            </Listeners>
                                        </ext:MenuItem>
                                    </Items>
                                </ext:Menu>
                            </Menu>
                        </ext:Button>
                    </Items>
                </ext:Toolbar>
                <ext:Toolbar runat="server" Dock="Bottom" AnchorHorizontal="100%">
                    <Items>
                        <ext:TriggerField ID="txtSearch" runat="server" Width="200" EnableKeyEvents="true" MarginSpec="0 8 0 0">
                            <Triggers>
                                <ext:FieldTrigger Icon="Search" />
                            </Triggers>
                            <DirectEvents>
                                <TriggerClick OnEvent="Search_Event"></TriggerClick>
                                <KeyUp OnEvent="Search_Event"></KeyUp>
                                <KeyPress OnEvent="Search_Event"></KeyPress>
                            </DirectEvents>
                        </ext:TriggerField>
                        <ext:SelectBox
                            ID="SelectBoxGroupUser"
                            runat="server"
                            Cls="x-select-box"
                            DisplayField="Group_Name"
                            ValueField="Group_Id"
                            MarginSpec="0 8 0 0"
                            EmptyText="Chọn nhóm quyền ">
                            <Store>
                                <ext:Store ID="StoreGroupUser" runat="server">
                                    <Model>
                                        <ext:Model runat="server">
                                            <Fields>
                                                <ext:ModelField Name="Group_Name" />
                                                <ext:ModelField Name="Group_Id" />
                                            </Fields>
                                        </ext:Model>
                                    </Model>
                                </ext:Store>
                            </Store>
                            <DirectEvents>
                                <Select OnEvent="SelectBoxGroupUser_Change">
                                    <EventMask ShowMask="true" Msg="Đang tải..."></EventMask>
                                </Select>
                            </DirectEvents>
                        </ext:SelectBox>
                        <ext:PagingToolbar ID="PagingToolbarUser" runat="server" StoreID="StoreUser" BeforePageText="Trang" AfterPageText="của {0}" LastText="Cuối" NextText="Kế tiếp" PrevText="Trở lại" FirstText="Đầu" RefreshText="Làm tươi" DisplayInfo="true" DisplayMsg="Trang {0} - {1} của {2}" />
                    </Items>
                </ext:Toolbar>
            </DockedItems>
        </ext:GridPanel>
    </Content>
</ext:Panel>
<ext:Panel runat="server">
    <Content>
        <%-----------WindowsGroupUser-----------------%>
        <ext:Window ID="WindowsUser" runat="server"
            Title="Người dùng"
            DefaultAnchor="100%"
            Width="407px"
            Height="421px"
            Hidden="true"
            AutoScroll="False"
            Maximizable="False"
            Minimizable="False"
            AutoDataBind="true"
            Region="Center"
            Resizable="False"
            Modal="true"
            HideMode="Offsets"
            Border="false"
            Padding="5"
            DefaultButton="btnSavePopUp">
            <Items>
                <ext:Toolbar ID="ToolbarGroupUser" runat="server">
                    <Items>
                        <ext:Button runat="server" Text="Lưu lại" Icon="Disk" ID="btnSavePopUp">
                            <DirectEvents>
                                <Click OnEvent="btnSavePopUp_Click" Before="return #{FormPanelUser}.isValid();">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button runat="server" Text="Thêm nhóm quyền" Icon="Add" ID="btnAddGroupUser">
                            <DirectEvents>
                                <Click OnEvent="btnAddGroupUser_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                         <ext:Button runat="server" Text="Thêm nhân viên" Icon="Add" ID="btnAddEmployee">
                            <DirectEvents>
                                <Click OnEvent="btnAddEmployee_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button runat="server" Text="Huỷ bỏ" Icon="Decline" ID="btnCancelPopUp">
                            <DirectEvents>
                                <Click OnEvent="btnCancelPopUp_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                    </Items>
                </ext:Toolbar>
                <ext:Hidden ID="hdIDGroupUser" runat="server" FieldLabel="ID Bank:" AllowBlank="false" Width="250" Visible="True" Margins="0 20 0 0"></ext:Hidden>
                <ext:Hidden ID="hdIDEmployee" runat="server" FieldLabel="ID Bank:" AllowBlank="false" Width="250" Visible="True" Margins="0 20 0 0"></ext:Hidden>
                <ext:Hidden ID="hdPasswords" runat="server" FieldLabel="ID Bank:" AllowBlank="false" Width="250" Visible="True" Margins="0 20 0 0"></ext:Hidden>
                <ext:Hidden ID="hdIDUser" runat="server" FieldLabel="ID Bank:" AllowBlank="false" Width="250" Visible="True" Margins="0 20 0 0"></ext:Hidden>
                <ext:FormPanel ID="FormPanelUser" runat="server"
                    BodyPadding="10"
                    Frame="true"
                    DefaultAnchor="100%">
                    <Items>
                        <ext:TextField ID="txtGroupUserName" ReadOnly="True" FieldCls="readonly" LabelAlign="Top" LabelStyle="font-weight: 600" runat="server" FieldLabel="Nhóm quyền (*)" AllowBlank="false" Width="250" Margins="0 20 0 0" /> 
                        <ext:TextField ID="txtEmployeeName" ReadOnly="True" FieldCls="readonly" LabelAlign="Top" LabelStyle="font-weight: 600" runat="server" FieldLabel="Tên nhân viên (*)" AllowBlank="false" Width="250" Margins="0 20 0 0" />
                        <ext:TextField ID="txtUserName" LabelAlign="Top" LabelStyle="font-weight: 600" runat="server" FieldLabel="Tên đăng nhập (*)" AllowBlank="false" Width="250" Margins="0 20 0 0" />
                        <ext:TextField ID="txtPassword" LabelAlign="Top" LabelStyle="font-weight: 600" runat="server" FieldLabel="Mật khẩu (*)" AllowBlank="false" Width="250" Margins="0 20 0 0" >
                             <Plugins>
                                <ext:PasswordMask ID="PasswordsInputMark" runat="server" />

                                <ext:CapsLockDetector runat="server">
                                    <Listeners>
                                        <CapsLockOn Handler="#{txtPassword}.showIndicator({iconCls : '#Error', tip : 'Đang bật Caps Lock'});" />
                                        <CapsLockOff Handler="#{txtPassword}.hideIndicator();" />
                                    </Listeners>
                                </ext:CapsLockDetector>
                            </Plugins>
                        </ext:TextField>
                        <ext:Checkbox ID="chkLock" LabelAlign="Top" LabelStyle="font-weight: 600" runat="server" FieldLabel="Khoá (*)" AllowBlank="false" Width="250" Margins="0 20 0 0" />
                        <ext:TextArea ID="txtNote" LabelAlign="Top" LabelStyle="font-weight: 600" runat="server" FieldLabel="Ghi chú" AnchorHorizontal="100%" Height="100" AllowBlank="True" FieldStyle="text-align:left;" />
                    </Items>
                </ext:FormPanel>
            </Items>
        </ext:Window>
        <%-----------WindowsGroupUser-----------------%>
        <ext:Window ID="WindowUserGroupUser" runat="server"
            Title="Thông tin nhóm quyền"
            DefaultAnchor="100%"
            Width="829"
            Height="400"
            Hidden="true"
            AutoScroll="false"
            Maximizable="False"
            Minimizable="False"
            AutoDataBind="true"
            Region="Center"
            Resizable="False"
            Modal="true"
            Layout="Fit"
            HideMode="Offsets"
            Constrain="True">
            <Content>
                <ext:GridPanel
                    ID="grUserGroupUser"
                    Border="True"
                    runat="server"
                    AutoWidth="true"
                    AutoScroll="true"
                    Cls="gird"
                    EnableColumnMove="true">
                    <Store>
                        <ext:Store
                            ID="StoreUserGroupUser"
                            runat="server"
                            OnReadData="StoreUserGroupUser_RefreshData"
                            PageSize="10">
                            <Model>
                                <ext:Model runat="server" IDProperty="Group_Id">
                                    <Fields>
                                        <ext:ModelField Name="Group_User_Code" Type="String" />
                                        <ext:ModelField Name="Group_Name" Type="String" />
                                    </Fields>
                                </ext:Model>
                            </Model>
                        </ext:Store>
                    </Store>
                    <ColumnModel runat="server">
                        <Columns>
                             <ext:RowNumbererColumn ID="RowNumbererColumnUserGroupUser" runat="server" Width="30" Align="Center" />
                            <ext:Column runat="server" Text="Tên User Control" Width="150" DataIndex="Group_User_Code"></ext:Column>
                            <ext:Column runat="server" Text="Tên Modules" Width="200" DataIndex="Group_Name"  Flex="1"></ext:Column>
                        </Columns>
                    </ColumnModel>
                    <SelectionModel>
                        <ext:CellSelectionModel runat="server">
                            <DirectEvents>
                                <Select OnEvent="UserGorupUser_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Select>
                            </DirectEvents>
                        </ext:CellSelectionModel>
                    </SelectionModel>
                    <DockedItems>
                        <ext:Toolbar runat="server" Dock="Bottom" AnchorHorizontal="100%">
                            <Items>
                                <ext:TriggerField ID="txtSearchUserGroupUserMain" runat="server" Width="200" EnableKeyEvents="true" MarginSpec="0 8 0 0">
                                    <Triggers>
                                        <ext:FieldTrigger Icon="Search" />
                                    </Triggers>
                                    <DirectEvents>
                                        <TriggerClick OnEvent="SearchUserGorupUser_Event"></TriggerClick>
                                        <KeyUp OnEvent="SearchUserGorupUser_Event"></KeyUp>
                                        <KeyPress OnEvent="SearchUserGorupUser_Event"></KeyPress>
                                    </DirectEvents>
                                </ext:TriggerField>
                                <ext:PagingToolbar ID="PagingToolbarUserGroupUser" runat="server" StoreID="StoreUserGroupUser" BeforePageText="Trang" AfterPageText="của {0}" LastText="Cuối" NextText="Kế tiếp" PrevText="Trở lại" FirstText="Đầu" RefreshText="Làm tươi" DisplayInfo="true" DisplayMsg="Trang {0} - {1} của {2}" />
                            </Items>
                        </ext:Toolbar>
                    </DockedItems>
                </ext:GridPanel>
            </Content>
        </ext:Window>
        <%-----------WindowsEmployee-----------------%>
        <ext:Window ID="WindowUserEmployee" runat="server"
            Title="Thông tin nhân viên"
            DefaultAnchor="100%"
            Width="829"
            Height="400"
            Hidden="true"
            AutoScroll="false"
            Maximizable="False"
            Minimizable="False"
            AutoDataBind="true"
            Region="Center"
            Resizable="False"
            Modal="true"
            Layout="Fit"
            HideMode="Offsets"
            Constrain="True">
            <Content>
                <ext:GridPanel
                    ID="grUserEmployee"
                    Border="True"
                    runat="server"
                    AutoWidth="true"
                    AutoScroll="true"
                    Cls="gird"
                    EnableColumnMove="true">
                    <Store>
                        <ext:Store
                            ID="StoreUserEmployee"
                            runat="server"
                            OnReadData="StoreUserEmployee_RefreshData"
                            PageSize="10">
                            <Model>
                                <ext:Model runat="server" IDProperty="Employee_Id">
                                    <Fields>
                                        <ext:ModelField Name="Bank_Code" Type="String" />
                                        <ext:ModelField Name="FullName" Type="String" />
                                    </Fields>
                                </ext:Model>
                            </Model>
                        </ext:Store>
                    </Store>
                    <ColumnModel runat="server">
                        <Columns>
                             <ext:RowNumbererColumn ID="RowNumbererColumnUserUserEmployee" runat="server" Width="30" Align="Center" />
                            <ext:Column runat="server" Text="Tên User Control" Width="150" DataIndex="Bank_Code"></ext:Column>
                            <ext:Column runat="server" Text="Tên Modules" Width="200" DataIndex="FullName"  Flex="1"></ext:Column>
                        </Columns>
                    </ColumnModel>
                    <SelectionModel>
                        <ext:CellSelectionModel runat="server">
                            <DirectEvents>
                                <Select OnEvent="UserEmployee_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Select>
                            </DirectEvents>
                        </ext:CellSelectionModel>
                    </SelectionModel>
                    <DockedItems>
                        <ext:Toolbar runat="server" Dock="Bottom" AnchorHorizontal="100%">
                            <Items>
                                <ext:TriggerField ID="txtSearchUserEmployee" runat="server" Width="200" EnableKeyEvents="true" MarginSpec="0 8 0 0">
                                    <Triggers>
                                        <ext:FieldTrigger Icon="Search" />
                                    </Triggers>
                                    <DirectEvents>
                                        <TriggerClick OnEvent="SearchUserEmployee_Event"></TriggerClick>
                                        <KeyUp OnEvent="SearchUserEmployee_Event"></KeyUp>
                                        <KeyPress OnEvent="SearchUserEmployee_Event"></KeyPress>
                                    </DirectEvents>
                                </ext:TriggerField>
                                <ext:PagingToolbar ID="PagingToolbarUserEmployee" runat="server" StoreID="StoreUserEmployee" BeforePageText="Trang" AfterPageText="của {0}" LastText="Cuối" NextText="Kế tiếp" PrevText="Trở lại" FirstText="Đầu" RefreshText="Làm tươi" DisplayInfo="true" DisplayMsg="Trang {0} - {1} của {2}" />
                            </Items>
                        </ext:Toolbar>
                    </DockedItems>
                </ext:GridPanel>
            </Content>
        </ext:Window>
    </Content>
</ext:Panel>